﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Web.UI;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for Common
/// </summary>
namespace Helper
{
    public static class Common
    {
        public static string GetPageName(Page currentPage)
        {
            return Path.GetFileName(currentPage.AppRelativeVirtualPath);
        }

        public static string GetPageNameWithoutExtension(Page currentPage)
        {
            return Path.GetFileNameWithoutExtension(currentPage.AppRelativeVirtualPath);
        }

        public static string SetIfActivePage(Page activePage,string pageName, string activePropertyText)
        {
            if (string.Compare(pageName.Trim(), GetPageName(activePage),true) == 0)
            {
                return activePropertyText;
            }
            return string.Empty;
        }
        public static string AppendPageTitle(MasterPage masterPage, string headerID, string title)
        {
            ((HtmlHead)masterPage.FindControl(headerID)).Title += title;
            return ((HtmlHead)masterPage.FindControl(headerID)).Title;
        }

        public static string SetPageTitle(MasterPage masterPage, string headerID, string title)
        {
            ((HtmlHead)masterPage.FindControl(headerID)).Title = title;
            return ((HtmlHead)masterPage.FindControl(headerID)).Title;
        }
    }
}